package com.cxria.pattern.observer.func2

def sh = new SHDnsServer()
def china = new ChinaDnsServer()
def top = new TopDnsServer()

china.upperServer = top
sh.upperServer = china

println '====域名解析模拟器===='

while (true){
    println '\n请输入域名(输入N退出):'
    def domain = new InputStreamReader(System.in).readLine()
    if(domain.equalsIgnoreCase('n')){
        return
    }
    def recorder = new Recorder()
    recorder.domain = domain
    sh.update(null, recorder)
    println '----DNS服务器解析结果----'
    println recorder
}